﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Sunny.Controls
{
	/// <summary>
	/// Button.xaml 的交互逻辑
	/// </summary>
	public partial class Button : Telerik.Windows.Controls.RadButton
	{


		public string Text
		{
			get { return (string)GetValue(TextProperty); }
			set { SetValue(TextProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty TextProperty =
			DependencyProperty.Register("Text", typeof(string), typeof(Button), new PropertyMetadata(null));



		public ImageSource Icon
		{
			get { return (ImageSource)GetValue(IconProperty); }
			set { SetValue(IconProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Icon.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty IconProperty =
			DependencyProperty.Register("Icon", typeof(ImageSource), typeof(Button), new PropertyMetadata(null));





		//public string Text
		//{
		//	get
		//	{
		//		return this.TextBlock.Text;
		//	}
		//	set
		//	{
		//		this.TextBlock.Text = value;
		//	}
		//}

		//public System.Windows.Media.ImageSource Icon
		//{
		//	get
		//	{
		//		return this.Image.Source;
		//	}
		//	set
		//	{
		//		if(value is BitmapSource)
		//		{
		//			BitmapSource bitmap = (BitmapSource)value;
		//			if (bitmap.DpiX == 96 && bitmap.DpiY == 96)
		//			{
		//				this.Image.Stretch = Stretch.None;
		//				this.Image.Width = double.NaN;
		//				this.Image.Height = double.NaN;
		//			}
		//			else
		//			{
		//				this.Image.Stretch = Stretch.Fill;
		//				this.Image.Width = bitmap.Width * bitmap.DpiX / 96;
		//				this.Image.Height = bitmap.Height * bitmap.DpiY / 96;
		//			}
		//		}

		//		this.Image.Source = value;
		//	}
		//}

		static Button()
		{
			DefaultStyleKeyProperty.OverrideMetadata(typeof(Button), new FrameworkPropertyMetadata(typeof(Button)));
		}

		public Button()
		{
			InitializeComponent();
		}
	}
}
